import httpProxy from "../utils/request"; // 拿到我们刚封装的axios
import { URL } from "../config";
// 获取验证码
export async function getVerity(h: number, w: number, inverse: number = 1) {
  return await httpProxy({
    url: `/admin/base/open/captcha?height=${h}&width=${w}&color=%23ffd111`,
    // url: `/capcha?height=${h}&width=${w}&inverse=${inverse}`,
    method: "GET",
  });
}

// 登录
export async function logIN(data: any) {
  return await httpProxy({
    url: `/admin/base/open/login`,
    method: "POST",
    data,
  });
}

// 无感刷新的接口
export async function refreshToken(params: any) {
  return await httpProxy({
    url: `/admin/base/open/refreshToken`,
    method: "GET",
    params,
  });
}
// 获取用户信息
export async function getPersonInfo() {
  return await httpProxy({
    url: `/admin/base/comm/person`,
    method: "GET",
  });
}
export async function getDataset(id: string) {
  return await httpProxy({
    url: `/admin/map-dataset/info/info?id=${id}`,
    method: "GET",
  });
}
export async function getFeatures(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/feature/page`,
    method: "POST",
    data,
  });
}

export async function getDatasets(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/info/page`,
    method: "POST",
    data,
  });
}
export async function getOpenDataset(id: string) {
  return await httpProxy({
    url: `/open/map-dataset/info/info?id=${id}`,
    method: "GET",
  });
}

export async function addDataset(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/info/add`,
    method: "POST",
    data,
  });
}
export async function updateDataset(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/info/update`,
    method: "POST",
    data,
  });
}

export async function upload(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/info/page`,
    method: "POST",
    data,
  });
}
export async function updateFeature(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/feature/update`,
    method: "POST",
    data,
  });
}
export async function deleteFeature(id: number) {
  return await httpProxy({
    url: `/admin/map-dataset/feature/delete`,
    method: "POST",
    data: { ids: [id] },
  });
}
export async function deleteAllFeature(ids: Array<number>) {
  return await httpProxy({
    url: `/admin/map-dataset/feature/delete`,
    method: "POST",
    data: { ids },
  });
}
export async function addFeature(data: any) {
  return await httpProxy({
    url: `/admin/map-dataset/feature/add`,
    method: "POST",
    data,
  });
}
export async function getFileList(data: any) {
  return await httpProxy({
    url: `/admin/storage/file/page`,
    method: "POST",
    data,
  });
}
export async function uplpadFile(data: any) {
  return await httpProxy({
    url: `/admin/storage/file/add`,
    method: "POST",
    data,
  });
}
export async function updateFile(data: any) {
  return await httpProxy({
    url: `/admin/storage/file/updateFile`,
    method: "POST",
    data,
  });
}
export async function recusiveDelete(data: any) {
  return await httpProxy({
    url: `/admin/storage/file/recusiveDelete`,
    method: "POST",
    data,
  });
}
export async function editFile(data: any) {
  return await httpProxy({
    url: `/admin/storage/file/editFile`,
    method: "POST",
    data: {
      uid: data.uid,
      data,
    },
  });
}
export async function getCurrentSize() {
  return await httpProxy({
    url: `/admin/storage/file/currentSize`,
    method: "POST",
  });
}
export async function getUserInfo() {
  return await httpProxy({
    url: `/admin/base/comm/person`,
    method: "GET",
  });
}
export async function getFileInfo(data) {
  return await httpProxy({
    url: `/admin/storage/file/file-info`,
    method: "POST",
    data,
  });
}

export async function addLayer(data) {
  return await httpProxy({
    url: `/admin/map-dataset/layer/add`,
    method: "POST",
    data,
  });
}
export async function updateLayer(data) {
  return await httpProxy({
    url: `/admin/map-dataset/layer/update`,
    method: "POST",
    data,
  });
}
export async function deleteLayer(data) {
  return await httpProxy({
    url: `/admin/map-dataset/layer/delete`,
    method: "POST",
    data,
  });
}
export async function uploadFile(data) {
  return await httpProxy({
    url: `/admin/base/comm/tmp-upload`,
    method: "POST",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}

export async function sendEmailApi(to: string) {
  return await httpProxy({
    url: `/user/send-email`,
    method: "GET",
    params: {
      email: to,
    },
  });
}

export async function registerEmailApi(data) {
  return await httpProxy({
    url: `/user/register/email`,
    method: "POST",
    data,
  });
}

export async function getSiteInfo() {
  return await httpProxy({
    url: `/admin/dict/info/list`,
    method: "POST",
    data: { typeId: 21, sort: "desc", order: "orderNum" },
  });
}
